/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.helper;

import com.ivanbiz.dao.LockDateDAO;
import com.ivanbiz.dao.impl.LockDateDAOImpl;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Aprisma
 */
public class ServiceHelper {

    public Object[] getPropertyClass(Class claz) {
        List listData = new ArrayList();
        Field[] fields = claz.getDeclaredFields();
        for (int x = 0; x < fields.length; x++) {
            Field field = (Field) fields[x];
            listData.add(field.getName());
        }
        Object[] data = new Object[listData.size()];
        for (int x = 1; x < listData.size(); x++) {
            data[x] = listData.get(x);
        }
        return data;
    }

    public String getMessages(String message) {
        Locale locale = new Locale("in_ID");
        ResourceBundle messages = ResourceBundle.getBundle(GlobalConstant.MESSAGE, locale);
        return messages.getString(message);
    }

    public Date getDateNow() {
        Date date = null;
        try {
            LockDateDAO dao = new LockDateDAOImpl();
            date = dao.getDateToday();
        } catch (Exception ex) {
            Logger.getLogger(ServiceHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
        return date;
    }
}
